package com.goods.controller.business;

import com.goods.business.service.ProductService;
import com.goods.common.model.business.ParamModel2;
import com.goods.common.model.business.ParamModel3;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.ProductStockVO;
import com.goods.common.vo.business.ProductVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 赵勇镔
 * @Time: 2021/6/8 15:19
 * @Description:
 */

// http://www.localhost:8989/business/product/findProductList?pageNum=1&pageSize=6&name=&categoryId=&supplier=&status=0

@Api(tags = "业务模块-物资资料")
@RestController
@RequestMapping("/business/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @ApiOperation(value = "物资资料", notes = "物资资料条件查询展示")
    @GetMapping("/findProductList")
    public ResponseBean<PageVO<ProductVO>> findProductList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                           ParamModel2 paramModel2) {
        PageVO<ProductVO> pageVOList = productService.findProductList(pageNum, pageSize, paramModel2);
        return ResponseBean.success(pageVOList);
    }

    @ApiOperation(value = "物资资料", notes = "物资资料添加")
    @PostMapping("/add")
    public ResponseBean add(@RequestBody ProductVO productVO) {
        productService.add(productVO);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资资料", notes = "物资资料修改回显")
    @GetMapping("/edit/{id}")
    public ResponseBean<ProductVO> edit(@PathVariable Long id) {
        ProductVO productVO = productService.edit(id);
        return ResponseBean.success(productVO);
    }

    @ApiOperation(value = "物资资料", notes = "物资资料修改保存")
    @PutMapping("/update/{id}")
    public ResponseBean update(@PathVariable Long id,@RequestBody ProductVO productVO) {
        productService.update(id,productVO);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资资料", notes = "物资资料添加回收站")
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id) {
        productService.remove(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资资料", notes = "物资资料回收站恢复")
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id) {
        productService.back(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资资料", notes = "物资资料回收站删除")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id) {
        productService.delete(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资资料", notes = "物资资料信息审核")
    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id) {
        productService.publish(id);
        return ResponseBean.success();
    }


    @ApiOperation(value = "物资库存", notes = "饼状图展示")
    @GetMapping("/findAllStocks")
    public ResponseBean<List<ProductStockVO>> findAllStocks(ParamModel3 paramModel3) {
        List<ProductStockVO> pageVO = productService.findAllStocks(paramModel3);
        return ResponseBean.success(pageVO);
    }

    @ApiOperation(value = "物资库存", notes = "柱状图展示")
    @GetMapping("/findProductStocks")
    public ResponseBean<PageVO<ProductStockVO>> findProductStocks(ParamModel3 paramModel3) {
        PageVO<ProductStockVO> ProductStockVOS = productService.findProductStocks(paramModel3);
        return ResponseBean.success(ProductStockVOS);
    }



}
